home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
010
/
blit.arc
/
RLAYEROP.C
< prev
next >
Wrap
Text File
|
1985-05-23
|
4KB
|
112 lines
/*
* name: rlayerop
*
* description: given a layer lp, a rectangle r, a bitmap operator fn,
* and the obscured list of the layer op, recursively chain
* along the obscured list of the layer, performing the
* operation on the intersection of the argument rectangle
* and the obscured bitmap, and pass nonintersecting portions on
* to be intersected with other bitmaps on the obscured list.
* when the obscured list is empty, the rectangle must be drawn
* on the screen.
*
* synopsis: rlayerop (lp, fn, r, op, p1, p2, p3, p4)
* struct layer *lp;
* int (*fn) ();
* struct rectangle *r;
* struct obscured *op;
* int *p1;
* int *p2;
* int *p3;
* int *p4;
*
* globals: display (r/w)
*
* calls: (*fn) <=> addpiece (addpiece.c) by newlayer (newlayer.c)
* lbblt (lbblt.c) lblt (lblt.c)
* pass (pass.c) lbitblt (lbitblt.c)
* rectxrect (rectxrect.c)
* rlayerop (rlayerop.c)
*
* called by: layerop (layerop.c)
* rlayerop (rlayerop.c)
*/
#include "layers.h"
extern struct bitmap *display;
rlayerop (lp, fn, r, op, p1, p2, p3, p4)
struct layer *lp;
int (*fn) ();
struct rectangle *r;
struct obscured *op; /* element of obscured list with which
to intersect r */
int *p1;
int *p2;
int *p3;
int *p4;
{
struct rectangle temp;
/*
* recursively subdivide and intersect rectangle r
* with the obscured bitmaps in layer lp.
*/
if (op == null) /* this rectangle is not obscured */
(void) (*fn) (lp, r, display, op, p1, p2, p3, p4);/* draw on screen */
else
if (rectxrect (r, &(op -> ob_rect)) == false)/* they miss */
(void) rlayerop (lp, fn, r, op -> ob_next, p1, p2, p3, p4);
/* chain */
else { /* they must intersect */
if (r -> origin.y < op -> ob_rect.origin.y) {
/*
* temp = piece of r below op -> rect;
*/
temp.origin.x = r -> origin.x;
temp.origin.y = r -> origin.y;
temp.corner.x = r -> origin.x;
temp.corner.y = op -> ob_rect.origin.y;
(void) rlayerop (lp, fn, &temp, op -> ob_next, p1, p2, p3, p4);
r -> origin.y = op -> ob_rect.origin.y;
}
if (r -> corner.y > op -> ob_rect.corner.y) {
/*
* temp = piece of r above op -> rect;
*/
temp.origin.x = r -> origin.x;
temp.origin.y = op -> ob_rect.corner.y;
temp.corner.x = r -> origin.x;
temp.corner.y = r -> origin.y;
(void) rlayerop (lp, fn, &temp, op -> ob_next, p1, p2, p3, p4);
r -> corner.y = op -> ob_rect.corner.y;
}
if (r -> origin.x < op -> ob_rect.origin.x) {
/*
* temp = piece of r to the left of op -> rect;
*/
temp.origin.x = r -> origin.x;
temp.origin.y = r -> origin.y;
temp.corner.x = op -> ob_rect.origin.x;
temp.corner.y = r -> origin.y;
(void) rlayerop (lp, fn, &temp, op -> ob_next, p1, p2, p3, p4);
r -> origin.x = op -> ob_rect.origin.x;
}
if (r -> corner.x > op -> ob_rect.corner.x) {
/*
* temp = piece of r right of op -> rect;
*/
temp.origin.x = op -> ob_rect.corner.x;
temp.origin.y = r -> origin.y;
temp.corner.x = r -> origin.x;
temp.corner.y = r -> origin.y;
(void) rlayerop (lp, fn, &temp, op -> ob_next, p1, p2, p3, p4);
r -> corner.x = op -> ob_rect.corner.x;
}
/*
* what's left goes in this obscured bitmap
*/
(void) (*fn) (lp, r, op -> ob_bmap, op, p1, p2, p3, p4);
}
}